package com.itc.bi.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Date;

@TableName("tb_table_column")
@ApiModel(value = "表字段",description = "表字段")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TableColumnEntity {
    @TableId(value = "id",type = IdType.ASSIGN_ID)
    @ApiModelProperty("主键")
    private Long id;

    @TableField(value = "table_id")
    @ApiModelProperty(value = "表ID")
    private Long tableId;

    @TableField(value = "datasource_id")
    @ApiModelProperty(value = "数据源ID")
    private Long datasourceId;

    @TableField(value = "column_name")
    @ApiModelProperty(value = "字段名")
    private String columnName;

    @TableField(value = "column_comment")
    @ApiModelProperty(value = "字段注释")
    private String columnComment;

    @TableField(value = "column_type")
    @ApiModelProperty(value = "字段类型")
    private String columnType;

    @TableField(value = "column_position")
    @ApiModelProperty(value = "字段位置")
    private Integer columnPosition;

    @TableField(value = "default_value")
    @ApiModelProperty(value = "字段默认值")
    private String defaultValue;

    @TableField(value = "Is_nullable")
    @ApiModelProperty(value = "字段是否为空")
    private String isNullable;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @ApiModelProperty(value = "创建时间",hidden = true)
    private Date createTime;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @ApiModelProperty(value = "修改时间",hidden = true)
    private Date updateTime;

    @TableField(exist = false)
    private String datasourceName;

    @TableField(exist = false)
    private String tableName;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "is_deleted")
    @ApiModelProperty(value = "删除状态",hidden = true)
    @TableLogic
    private boolean isDeleted;

    public TableColumnEntity(String columnName,String columnType){
        this.columnName=columnName;
        this.columnType=columnType;
    }

}
